package com.uvnos4j.matilda.commons.config;

import com.uvnos4j.matilda.commons.utils.Const;
import org.springframework.boot.web.server.ErrorPage;
import org.springframework.boot.web.server.ErrorPageRegistrar;
import org.springframework.boot.web.server.ErrorPageRegistry;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Component;

/**
 * Web 配置
 * <p>
 * Description:Web 配置 Class
 * </p>
 *
 * @author Guo.wl
 * @version v1.0.0
 * @since 2020-08-01 22:48:30
 */
@Component
public class WebConfig implements ErrorPageRegistrar {

    @Override
    public void registerErrorPages(ErrorPageRegistry registry) {
        // 404被tomcat容器拦截了 到不了controller 也就到不了 @ControllerAdvice
        ErrorPage e404 = new ErrorPage(HttpStatus.NOT_FOUND, Const.REQUEST_404_MAPPING);
        registry.addErrorPages(e404);
    }
}